const Angular = require('angular');
import config from './config';
import httpConfig from './config/httpConfig'
import '../mock/index'
import $ from './lib/jquery-vendor';
import _ from './lib/lodash-vendor';
import 'semantic-ui/dist/semantic.css'
import 'semantic-ui/dist/semantic.js'
import 'ztree';
import 'ztree/css/zTreeStyle/zTreeStyle.css'
require('oclazyload');
require('./module/page5/page5Module');
require('./module/selfService/selfServicePageModule');
import page3Fn from './page3/page3Module';
import './styles/main.scss';
page3Fn(Angular);

const ngModule = Angular.module('myApp', [require('angular-ui-router'), 'oc.lazyLoad', 'page3App', 'selfServiceApp']);
httpConfig(ngModule);
config(ngModule, Angular)
ngModule.config(function ($httpProvider) {
  $httpProvider.interceptors.push('myInterceptor');
})
ngModule.run(['$rootScope', '$location', '$timeout', function ($rootScope, $location, $timeout) {
  $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
    // console.log(event, toState, toParams, fromState, fromParams)
    // const projectId = localStorage.getItem('projectId');
    // if (toState.name != 'feng.page1') {
    //   if (!projectId) {
    //     event.preventDefault();
    //     $timeout(()=>{
    //       $location.path('/page1')
    //     })
    //   }
    // }
    $rootScope.authPromise = new Promise( (resolve, reject)=>{
        $timeout(()=>{
          resolve();
        },2000)
    })
  })
}]);
ngModule.controller('mainCtrl', ['$scope', '$http', function ($scope, $http) {
  // console.log($scope);
  function getMenuList() {
    $http.get('/getMenuList').then(function (res) {
      // console.log(res);
      $scope.menuList = res.list;
    })
  }

  getMenuList();
}])
